home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9376 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Crash Proofing?
  5. Date: 9 Mar 1996 16:15 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <9MAR199616155785@erich.triumf.ca>
  9. References: <4hsfje$rbr@uwm.edu>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4hsfje$rbr@uwm.edu>, peterk@alpha2.csd.uwm.edu (Peter J Kleczka) writes...
  14. ....
  15. >    The program I'm working on (below) works fine as long
  16. >as the user enters an integer.....but it gets caught in an
  17. >endless loop between the functions: firstmenu() and firstchoice()
  18. >when I enter, say, 5.5 instead of an integer
  19.  
  20. snip,snip...
  21.  
  22. >unsigned choice;
  23. >scanf ("%d", &choice);
  24.  
  25. Don't use scanf() for user input - use fgets() instead, then you can use
  26. sscanf(), atoi(), and other functions to process the input, and can check 
  27. for, and reject, bad input.
  28.  
  29. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  30. Internet: bennett@triumf.ca         | of one another only when one can be
  31. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  32. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  33. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  34. or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.